public class StringAdd {
    public static void main(String[] args) {
//        String nums1 = "11";
//        String nums2 = "123";
//        String nums1 = "456";
//        String nums2 = "77";
        String nums1 = "0";
        String nums2 = "0";
        System.out.println(addStrings(nums1, nums2));
    }

    public static String addStrings(String num1, String num2) {
        StringBuilder sb = new StringBuilder();
        int numFirstIndex = num1.length()-1;
        int numSecondIndex = num2.length()-1;
        int carry = 0;
        while(numFirstIndex >=0 || numSecondIndex>=0 || carry>0){
            int left = numFirstIndex >=0 ? num1.charAt(numFirstIndex) - '0' : 0;
            int right = numSecondIndex>=0 ?num2.charAt(numSecondIndex) - '0' :0;
            int sum = left + right + carry;
            sb.append(sum%10);
            carry =sum/10;
            numFirstIndex--;
            numSecondIndex--;
        }
        return sb.reverse().toString();
    }
}
